package com.ruoyi.project.declaration.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.declaration.domain.ProjectRecord;
import com.ruoyi.project.declaration.service.IProjectRecordService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 工程申报记录Controller
 * 
 * @author Daniel
 * @date 2020-04-01
 */
@RestController
@RequestMapping("/declaration/record")
public class ProjectRecordController extends BaseController
{
    @Autowired
    private IProjectRecordService projectRecordService;

    /**
     * 查询工程申报记录列表
     */
    @PreAuthorize("@ss.hasPermi('declaration:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectRecord projectRecord)
    {
        startPage();
        List<ProjectRecord> list = projectRecordService.selectProjectRecordList(projectRecord);
        return getDataTable(list);
    }

    /**
     * 导出工程申报记录列表
     */
    @PreAuthorize("@ss.hasPermi('declaration:record:export')")
    @Log(title = "工程申报记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProjectRecord projectRecord)
    {
        List<ProjectRecord> list = projectRecordService.selectProjectRecordList(projectRecord);
        ExcelUtil<ProjectRecord> util = new ExcelUtil<ProjectRecord>(ProjectRecord.class);
        return util.exportExcel(list, "record");
    }

    /**
     * 获取工程申报记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('declaration:record:query')")
    @GetMapping(value = "/{prid}")
    public AjaxResult getInfo(@PathVariable("prid") Long prid)
    {
        return AjaxResult.success(projectRecordService.selectProjectRecordById(prid));
    }

    /**
     * 新增工程申报记录
     */
    @PreAuthorize("@ss.hasPermi('declaration:record:add')")
    @Log(title = "工程申报记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectRecord projectRecord)
    {
        return toAjax(projectRecordService.insertProjectRecord(projectRecord));
    }

    /**
     * 修改工程申报记录
     */
    @PreAuthorize("@ss.hasPermi('declaration:record:edit')")
    @Log(title = "工程申报记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectRecord projectRecord)
    {
        return toAjax(projectRecordService.updateProjectRecord(projectRecord));
    }

    /**
     * 删除工程申报记录
     */
    @PreAuthorize("@ss.hasPermi('declaration:record:remove')")
    @Log(title = "工程申报记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{prids}")
    public AjaxResult remove(@PathVariable Long[] prids)
    {
        return toAjax(projectRecordService.deleteProjectRecordByIds(prids));
    }
}
